package com.quanquan.store.repository;

import com.quanquan.store.entity.Floor;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @ClassName:FloorRepository
 * @Description:楼层dao
 * @Author:xiongjunbao
 * @Date:2019/3/13 9:37
 * @Version 1.0
 */
public interface FloorRepository extends JpaRepository<Floor,String> {

    /**
     * 通过楼层查询
     * @param floorName
     * @return
     */
    @Query(value = "SELECT * FROM oo_floor WHERE floor_name = ?1 AND status_show = 0 AND status_remove = 0 ORDER BY sort_order ASC",nativeQuery = true)
    Floor findByFloorName(String floorName);

    /**
     * 根据楼层id查询
     *
     * @param id
     * @return
     */
    @Query(value = "SELECT * FROM oo_floor WHERE id = ?1 AND status_show = 0 AND status_remove = 0 ORDER BY sort_order ASC",nativeQuery = true)
    Floor findByIdAndStatusShow(String id);

    /**
     * 根据楼层id查询
     *
     * @param id
     * @return
     */
    @Query(value = "SELECT * FROM oo_floor WHERE id = ?1 AND status_remove = 0 ORDER BY sort_order ASC",nativeQuery = true)
    Floor findByFloorId(String id);


    @Query(value = "SELECT * FROM oo_floor WHERE status_show = 0 AND status_remove = 0 ORDER BY sort_order ASC", nativeQuery = true)
    List<Floor> list();
}
